package com.hzit.proxy.user;


import com.alibaba.fastjson.JSONObject;
import com.hzit.net.util.WXNetUtil;
import com.hzit.proxy.base.AccessToken;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class UserInfoProxy {
  public List<Map<String,Object>> getUserInfo(){
      String token = AccessToken.getToken();
      UserListProxy userListProxy = new UserListProxy();
      List<String> userList = userListProxy.getUserList(null);
      ArrayList<Map<String, Object>> list = new ArrayList<Map<String, Object>> ();
    for(String openId:userList){
      String url="https://api.weixin.qq.com/cgi-bin/user/info?access_token="+token+"&openid="+openId+"&lang=zh_CN";
        String result = WXNetUtil.get(url);
        JSONObject jsonObject = JSONObject.parseObject(result);
        if(jsonObject.containsKey("openid")){
            Map<String, Object> map = jsonObject.getInnerMap();
            list.add(map);
        }
    }
      return list;

  }

    public static void main(String[] args) {
        UserInfoProxy userInfoProxy = new UserInfoProxy();
        List<Map<String, Object>> userInfo = userInfoProxy.getUserInfo();
        for(Map<String, Object> list:userInfo){
            System.out.println(list);
        }
    }

}
